﻿using System;
using System.Collections.Generic;

namespace Tomato.Allure
{
	internal class ServiceImpl : IService
	{
		private EngineImpl m_engine = null;
		
		private AddOnInfo m_addOnInfo = null;

		private Queue<AllureEvent> m_allureEvents = null;

		public AddOnInfo AddOnInfo
		{
			get { return m_addOnInfo; }
		}

		public IVisualStudio VisualStudio
		{
			get { return m_engine.VisualStudio; }
		}

		public DateTime StartUpTime
		{
			get { return m_engine.StartUpTime; }
		}

		public ServiceImpl( EngineImpl allureEngine, AddOnInfo addOnInfo )
		{
			m_engine = allureEngine;
			
			m_addOnInfo = addOnInfo;

			m_allureEvents = new Queue<AllureEvent>();
		}

		public bool HandleAllureEvent( AllureEvent allureEvent )
		{
			if( m_addOnInfo.Instance != null )
			{
				return m_addOnInfo.Instance.OnEvent( this, allureEvent );
			}

			return false;
		}

		public bool HandleAllureException( AllureException allureException )
		{
			if( m_addOnInfo.Instance != null )
			{
				return m_addOnInfo.Instance.OnException( this, allureException );
			}

			return false;
		}
	}
}
